package atomic.counter;

import java.util.concurrent.atomic.LongAccumulator;

/**
 * 使用 LongAccumulator
 *
 * @author <a href='https://gitee.com/hzf2281'>codefish</a>
 * @version 1.0.0
 * @since 2022/08/21 下午 07:15
 */
public class LongAccumulatorCounter implements Counter {
    LongAccumulator longAccumulator = new LongAccumulator((x, y) -> x + y, 0);

    @Override
    public void increment() {
        longAccumulator.accumulate(1);
    }

    @Override
    public long getCount() {
        return longAccumulator.get();
    }
}
